package 迭代器;

import java.util.Iterator;

public class InfoCollegeIterator implements Iterator<DepartMent> {
    private DepartMent[] departMents;
    int index = -1;
    int size;// 实际个数

    public InfoCollegeIterator(DepartMent[] departMents,int size) {
        this.departMents = departMents;
        this.size = size;
    }

    @Override
    public boolean hasNext() {
        if (index < size - 1){ // -1
            index++;
            return true;
        }
        return false;
    }

    @Override
    public DepartMent next() {
        return departMents[index];
    }
}
